import os
import platform

__author__ = 'weixin.yuan'

PROJECT_PATH = os.path.dirname(os.path.dirname(__file__))
TOMCAT_HOME = '/Library/tomcat/webapps'
CONFIG_PATH = PROJECT_PATH + '/config'  # 配置文件路径


def get_report_dir():
    import socket
    # ip = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
    ip = '100.81.136.54'
    if ip != "100.81.136.54":
        report_dir = PROJECT_PATH + '/report'  # 测试报告与图片路径
        train_log_path = PROJECT_PATH + '/log/train'  # 运行时日志路径
        appium_log_path = PROJECT_PATH + '/log/appium'  # appium日志路径
    else:
        report_dir = TOMCAT_HOME + '/report'  # mac 服务器tomcat地址
        train_log_path = TOMCAT_HOME + '/log/train'  # 运行时日志路径
        appium_log_path = TOMCAT_HOME + '/log/appium'  # appium日志路径
    try:
        for path in (report_dir, train_log_path, appium_log_path):
            not_and_create(path)
    except IOError:
        raise IOError('请确认项目或者tomcat目录是否有可写权限')
    return {
        'report_dir': report_dir,
        'train_log_path': train_log_path,
        'appium_log_path': appium_log_path
    }


def not_and_create(path):
    if not os.path.exists(path):
        os.mkdir(path)

# ANYPROXY = "/Users/weshare/Documents/weshare/anyproxy_new"


path_list = get_report_dir()
REPORT = path_list['report_dir']
TRAIN_LOG_PATH = path_list['train_log_path']
APPIUM_LOG_PATH = path_list['appium_log_path']
APK = PROJECT_PATH + '/apk/qunar.apk'  # apk路径
# IPA = PROJECT_PATH + '/apk/openSchema.ipa'  # ipa路径
IPA = '/Users/qitmac000285/tmp/openSchema.ipa'  # ipa路径
SCHEMA_FILE_ADR = PROJECT_PATH + '/data/schemaurls.txt'
SCHEMA_FILE_IOS = PROJECT_PATH + '/data/schemaurls.ini'


if __name__ == '__main__':
    import socket
    ip = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
    print(ip)
